class Solution {
public:
    string getPermutation(int n, int k) {
        vector<int> num(n);
        for (int i = 0; i < n; i++) num[i] = i + 1;
        k -= 1;
        while (k--) {
            next_permutation(num.begin(), num.end());
        }
        string s = "";
        for (int i = 0; i < num.size(); i++) {
            s.push_back(num[i] + '0');
        }
        return s;
    }
};
